package com.example.smart_video.ui.activity;

import androidx.databinding.DataBindingUtil;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

import com.example.cleandemo3.R;
import com.example.cleandemo3.databinding.ActivityPlayImageBinding;
import com.wink_172.library.activity.SmartActivity;
import com.wink_172.library.view.ActionBarView;

import org.xutils.image.ImageOptions;
import org.xutils.x;

/**
 * 播放单个图片源
 */
public class PlayImageActivity extends SmartActivity {
    public ActivityPlayImageBinding binding;

    public static void startActivity(Context context, Object... args) {
        Intent intent = new Intent(context, PlayImageActivity.class);

                intent.putExtra(com.wink_172.library.model.Constants.PARAM_DATA1, (String) args[0]);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_play_image);
        binding.setOnClickListener(this);
        initView();
        init();
    }

    public void initView() {
        ((ActionBarView) binding.actionBar).updateAllContent(R.mipmap.icon_nav_arrow, getString(R.string.wink314), "");
        ((ActionBarView) binding.actionBar).setCallback(new ActionBarView.ICallback() {
            @Override
            public void onSendEvent(int event, String content) {
                if (event == ActionBarView.LEFT_BTN) {
                    finish();
                }
            }
        });
    }

    private  final String TAG = "PlayImageActivity";
    private void init() {
        String url = getIntent().getStringExtra(com.wink_172.library.model.Constants.PARAM_DATA1);

        Log.e(TAG, "init: ====>>"+url );
        ImageOptions options = new ImageOptions.Builder()
                .setUseMemCache(true)
                .setFadeIn(true)
           .setImageScaleType(ImageView.ScaleType.CENTER)
                .build();

        x.image().bind((ImageView) binding.imageView, url,options);

    }
}